//CHART_REPO := http://jenkins-chartmuseum:8080
CURRENT=$(pwd)
NAME := $(FILE_NAME)
OS := $(shell uname)
IMAGE_NAME := $(Artifact_ID)
K8S_persistence_enabled := ${K8S_persistence_enabled}
K8S_persistence_subpath := ${K8S_persistence_subpath}
K8S_env_appParams := ${K8S_env_appParams}
K8S_env_javaParams := ${K8S_env_javaParams}
K8S_health_path := ${K8S_health_path}
K8S_SIT_appParams :=  ${K8S_SIT_appParams}
K8S_SIT_javaParams :=  ${K8S_SIT_javaParams}
K8S_UAT_appParams :=  ${K8S_UAT_appParams}
K8S_UAT_javaParams :=  ${K8S_UAT_javaParams}
K8S_DEMO_appParams :=  ${K8S_DEMO_appParams}
K8S_DEMO_javaParams :=  ${K8S_DEMO_javaParams}
K8S_jvmCacerts_enabled := ${K8S_jvmCacerts_enabled}
K8S_BUG_appParams :=  ${K8S_BUG_appParams}
K8S_BUG_javaParams :=  ${K8S_BUG_javaParams}
K8S_restart_policy := ${K8S_restart_policy}
PROJECT_NAME := ${PROJECT_NAME}


replace:
ifeq ($(OS),Linux)
	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" skaffold.yaml

	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/dev/values.yaml
	sed -i -e "s|ENV_APP_PARAMS|$(K8S_env_appParams)|" charts/dev/values.yaml
	sed -i -e "s|ENV_JAVA_PARAMS|$(K8S_env_javaParams)|" charts/dev/values.yaml
	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/dev/requirements.yaml

	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/preview/values.yaml
	sed -i -e "s|ENV_APP_PARAMS|$(K8S_SIT_appParams)|" charts/preview/values.yaml
	sed -i -e "s|ENV_JAVA_PARAMS|$(K8S_SIT_javaParams)|" charts/preview/values.yaml
	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/preview/requirements.yaml

	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/demo/values.yaml
	sed -i -e "s|ENV_APP_PARAMS|$(K8S_DEMO_appParams)|" charts/demo/values.yaml
	sed -i -e "s|ENV_JAVA_PARAMS|$(K8S_DEMO_javaParams)|" charts/demo/values.yaml
	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/demo/requirements.yaml

	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/bug/values.yaml
	sed -i -e "s|ENV_APP_PARAMS|$(K8S_BUG_appParams)|" charts/bug/values.yaml
	sed -i -e "s|ENV_JAVA_PARAMS|$(K8S_BUG_javaParams)|" charts/bug/values.yaml
	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/bug/requirements.yaml

	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/$(IMAGE_NAME)/Chart.yaml
	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" charts/$(IMAGE_NAME)/values.yaml
	sed -i -e "s|HEALTH_PATH|$(K8S_health_path)|" charts/$(IMAGE_NAME)/values.yaml
	sed -i -e "s|Always|$(K8S_restart_policy)|" charts/$(IMAGE_NAME)/values.yaml

	sed -i -e "s|ENV_APP_PARAMS|$(K8S_UAT_appParams)|" charts/$(IMAGE_NAME)/values.yaml
	sed -i -e "s|ENV_JAVA_PARAMS|$(K8S_UAT_javaParams)|" charts/$(IMAGE_NAME)/values.yaml

	sed -i -e "s/P_ENABLED/$(K8S_persistence_enabled)/" charts/$(IMAGE_NAME)/values.yaml
	sed -i -e "s/SUBPATH_NAME/$(K8S_persistence_subpath)/" charts/$(IMAGE_NAME)/values.yaml
	sed -i -e "s/JVM_CACERTS_ENABLED/$(K8S_jvmCacerts_enabled)/" charts/$(IMAGE_NAME)/values.yaml

	sed -i -e "s|PROJECT_NAME|$(PROJECT_NAME)|" charts/$(IMAGE_NAME)/values.yaml

	sed -i -e "s/IMAGE_NAME/$(IMAGE_NAME)/" dockerfile/dockerfile-k8s
else
	echo "platfrom $(OS) not supported to release from"
	exit -1
endif